package com.flx.dis.registry.zk.controller;

import com.flx.common.utils.result.ResultResponse;
import com.flx.dis.registry.zk.service.MonitorService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Fenglixiong
 * @Create 2022/4/19 17:40
 * @Description zk监控功能，启动可以实时查看服务器的cpu，磁盘等信息变化
 **/
@Api
@Slf4j
@RestController
@RequestMapping("/zk")
public class ZkMonitorController {

    @Autowired
    private MonitorService monitorService;

    @GetMapping("/startMonitor")
    public ResultResponse startMonitor(){
        try{
            monitorService.startMonitor();
            return ResultResponse.success("启动zk监控成功！");
        }catch (Exception e){
            log.error("启动zk监控失败，message = {}",e.getCause().toString());
            return ResultResponse.error("启动zk监控失败！");
        }
    }

}
